package com.lengxf.pay.wx.bean;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.XmlUtil;
import lombok.Data;
import org.w3c.dom.Document;

import java.util.Map;

@Data
public class BarcodeResult {

    //返回状态码
    private String returnCode;

    //返回信息
    private String returnMsg;

    //公众账号ID
    private String appid;

    //商户号
    private String mchId;

    //设备号
    private String deviceInfo;

    //随机字符串
    private String nonceStr;

    //签名
    private String sign;

    //业务结果
    private String resultCode;

    //错误代码
    private String errCode;

    //错误代码描述
    private String errCodeDes;

    //用户标识
    private String openid;

    //是否关注公众账号
    private String isSubscribe;

    //交易类型
    private String tradeType;

    //付款银行
    private String bankType;

    //货币类型
    private String feeType;

    //订单金额
    private String totalFee;

    //应结订单金额
    private String settlementTotalFee;

    //代金券金额
    private String couponFee;

    //现金支付货币类型
    private String cashFeeType;

    //现金支付金额
    private String cashFee;

    //微信支付订单号
    private String transactionId;

    //商户订单号
    private String outTradeNo;

    //商家数据包
    private String attach;

    //支付完成时间
    private String timeEnd;

    //营销详情
    private String promotionDetail;


    public static BarcodeResult resultToBean(String xml) {
        Document document = XmlUtil.parseXml(xml);
        Map<String, Object> stringObjectMap = XmlUtil.xmlToMap(document);
        return BeanUtil.mapToBean((Map<?, ?>) stringObjectMap.get("xml"), BarcodeResult.class, true, null);
    }

}
